package com.kid.kidliving.commodity.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;

import com.kid.common.valid.EnumValidate;
import com.kid.common.valid.SaveGroup;
import com.kid.common.valid.UpdateGroup;
import com.kid.common.valid.UpdateIsShowFroup;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

/**
 * 家居品牌
 * 
 * @author kid
 * @email kid@gmail.com
 * @date 2025-09-08 23:58:01
 */
@Data
@TableName("commodity_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * id
	 * @NotNull(message = "修改要求指定id",groups = {UpdateGroup.class})在UpdateGroup校验组生效
	 * @Null(message = "添加不能指定id",groups = {SaveGroup.class})在SaveGroup校验组生效
	 */
	@TableId
	@NotNull(message = "修改要求指定id",groups = {UpdateGroup.class, UpdateIsShowFroup.class})
	@Null(message = "添加不能指定id",groups = {SaveGroup.class})
	private Long id;
	/**
	 * 品牌名
	 * @NotBlank 表示非空并且必须包含一个非空字符
	 */
	@NotBlank(message = "品牌名不能为空",groups = {SaveGroup.class,UpdateGroup.class})
	private String name;
	/**
	 * logo
	 */
	@NotBlank(message = "logo不能为空",groups = {SaveGroup.class})
	@URL(message = "logo不是一个合法的URL",groups = {SaveGroup.class,UpdateGroup.class})
	private String logo;
	/**
	 * 说明
	 */
	private String description;
	/**
	 * 显示
	 * @NotNull 可以接受任意类型，不为空
	 * @NotBlank 不支持Integer类型，会报错
	 * 正则表达式不能用在数值类型
	 */
	@NotNull(message = "显示状态不能为空",groups = {SaveGroup.class,UpdateGroup.class, UpdateIsShowFroup.class})
	@EnumValidate(values = {0,1},message = "显示状态的值需要为0或1",groups = {SaveGroup.class, UpdateIsShowFroup.class})
	//@EnumValidate(regexp = "^[0-9]$",message = "显示状态的值需要为0或1",groups = {SaveGroup.class,UpdateGroup.class})
	private Integer isshow;
	/**
	 * 检索首字母
	 * String类型可以使用@Pattern进行验证
	 */
	@NotBlank(message = "检索首字母不能为空",groups = {SaveGroup.class})
	@Pattern(regexp = "^[a-zA-Z]$",message = "检索首字母必须在a-z或A-Z之间",groups = {SaveGroup.class,UpdateGroup.class})
	private String firstLetter;
	/**
	 * 排序
	 */
	@NotNull(message = "排序值不能为空",groups = {SaveGroup.class})
	@Min(value = 0,message = "排序值要求大于等于0",groups = {SaveGroup.class,UpdateGroup.class})
	private Integer sort;

}
